//
//  QMoneyAccountVC.m
//  QoilPublic
//
//  Created by 杨凯 on 16/8/17.
//  Copyright © 2016年 杨凯. All rights reserved.
//

#import "QMoneyAccountVC.h"

@interface QMoneyAccountVC ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation QMoneyAccountVC{

    UITableView *_tableView;
    NSArray *_imageArr;
    NSArray *_titleArr;
    
    NSInteger _index;
}

- (instancetype)initWithBlock:(Mblock)block{
    
    self = [super init];
    if(self){
        _block = block;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"账户";
    _index = 0;
    _imageArr = @[@"xMoney_image",@"yMoney_image",@"creditcard_image"];
    _titleArr = @[@"现金",@"会员余额",@"信用卡"];
    [self createTableView];
}

- (void)createTableView{
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) style:UITableViewStyleGrouped];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    [self.view addSubview:_tableView];
}

#pragma mark --- tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return _imageArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identify = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify];
    if(!cell){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identify];
    }
    cell.imageView.image = [UIImage imageNamed:_imageArr[indexPath.row]];
    cell.textLabel.text = _titleArr[indexPath.row];
    cell.textLabel.textColor = [QColorUtility defaultBackColor];
    cell.textLabel.font = [UIFont systemFontOfSize:Ksize16];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 0.01;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 0.01;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return [[UIView alloc] init];
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [[UIView alloc] init];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 50;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if(_block){
        NSString *moneyId = [NSString stringWithFormat:@"%d",indexPath.row+1];
        _block(_titleArr[indexPath.row],moneyId);
        [self.navigationController popViewControllerAnimated:YES];
    }
}



@end
